﻿@using Kugar.UI.Web.AdminLTE.Enums
@using Kugar.UI.Web.AdminLTE.Helpers
@using Kugar.UI.Web.AdminLTE.Helpers.FormExtMethod
@using Kugar.UI.Web.AdminLTE.PageControls.PageForms
@using Newtonsoft.Json.Linq
@using Kugar.UI.Web.AdminLTE.PageControls
@using Kugar.UI.Web.AdminLTE.PageControls.Helpers.ButtonExtMethod

@{
    WebUI.Title = "测试1比较长的标题";

    WebUI.TabPageTitle = "短标题";

    WebUI.CurrentMenuKey = "InnerTest1";

    WebUI.Breadcrumbs = new[]
    {
        new BreadcrumbItem("InnerTest2", "/IFrameTest/InnerTest2"),
        new BreadcrumbItem("InnerTest1", "/IFrameTest/InnerTest1"),
    };
}

@section scripts{
    <script>
        function addRow() {
            var tr = $('<tr class="odd" role="row">' +
                '<td class="" style = "" >' +
                '<div class="webui_data_cell ">' +
                '<input type="checkbox" id="" value="2" name="cc" title="" lay-skin="primary">' +
                '<div class="clearfix"></div>' +
                '</div>' +
                '</td>' +
                '<td class="" style="">' +
                '<div class="webui_data_cell ">' +
                '<input type="radio" id="" value="2" name="rr" title="" lay-skin="primary">' +
                '<div class="clearfix"></div>' +
                '</div>' +
                '</td>' +
                '<td class="" style="">' +
                '<div class="webui_data_cell "><span style="color:cornflowerblue;">ssssss</span>' +
                '<div class="clearfix"></div>' +
                '</div>' +
                '</td>' +
                '<td class="" style="">' +
                '<div class="webui_data_cell "><div>' +
                '<button class="btn btn-default" type="button">btn</button>' +
                '</div>' +
                '<div class="clearfix"></div>' +
                '</div>' +
                '</td>' +
                '<td class="" style="">' +
                '<div class="webui_data_cell "><span><span style="color:cornflowerblue;">Label</span></span><div class="clearfix"></div>' +
                '</div>' +
                '</td>' +
                '<td class="" style="">' +
                '<div class="webui_data_cell "><input lay-ignore="" class="form-control textbox" id="" name="tt" value="Textbox" placeholder=""> <div class="clearfix"></div>' +
                '</div>' +
                '</td>' +
                '<td class="" style="">' +
                '<div class="webui_data_cell "><select id="" class="form-control" lay-ignore="" onchanged="" name="ss">' +
                '<option value="-1">select</option>' +
                '<option value="0" selected="">s0</option>' +
                '<option value="1">s1</option>' +
                '</select>' +
                '<div class="clearfix"></div>' +
                '</div>' +
                '</td>' +
                '<td class="" style="">' +
                '<div class="webui_data_cell "><div class="input-group" id="">' +
                '<input lay-ignore="" readonly="" class="form-control textbox" name="tb" value="ddd" placeholder="">' +
                '<input type="hidden" value="101" name="tbID">' +
                '<span class="input-group-btn">' +
                '<button type="button" class="btn btn-success" data-showdatapicker="/Home/DataPicker" data-selectedcallback="OnSelectedCallback" data-showcallback="OnShowCallback" data-option="{&quot;StoreInCache&quot;:false}">select</button></span>' +
                '</div>' +
                '<div class="clearfix"></div>' +
                '</div>' +
                '</td>' +
                '</tr>');

            //var table = $("#table").data("jquerydatatable");
            //table.row.add(tr);
            //table.draw();

            $("#table").DataTable().row.add(tr).draw();

            layui.form.render('checkbox');
            layui.form.render('radio');
        }
    </script>
}

@using (var frm = WebUI.Control.Form().WithBox().Enctype(FormEnctype.multipart).Post().Render())
{
    @frm.AddCustomContent().Label("CustomContent").Content(@<div>
        @WebUI.Control.Button().Text("showModal").ShowModal("/Home/ModalWindow").Type(ButtonTypeEnum.button).Color(ColorPaletteEnum.success).Render()
    </div>).Render()

    @frm.AddSummerNote().Label("SummerNote").UploadUrl("/Home/UploadFile").Name("sum").Height("100px").ControlWidth("100%").Render()

    using (frm.AddCustomContainer().Required().Label("Container").WithNameError("Container").Render())
    {
        @frm.AddCustomContent().LabelWidth(0).Content(@<div>
            @WebUI.Control.Button().Text("addRow").OnClick("addRow();").Type(ButtonTypeEnum.button).Color(ColorPaletteEnum.success).Render()
        </div>).Render()

        using (var tb = WebUI.Control.Table<object>().ID("table").Data(new object[0]).FillRowCount(5).AddRowHiddenValue(x => ("hide", $"{x}")).NoWrap().Render())
        {
            @tb.Columns.AddCheckbox().ColumnTitle("").Checked(x => true).Name(x => "cc").Label(x => "").Value(x => tb.CurrentRowIndex.ToString())

            @tb.Columns.AddRadio().ColumnTitle("Radio").Checked(x => true).Name(x => "rr").Label(x => "").Value(x => tb.CurrentRowIndex.ToString())

            @tb.Columns.AddCustomContent().ColumnTitle("custom").Content(x => "<span style='color:cornflowerblue;'>ssssss</span>")

            @tb.Columns.AddCustomContent().ColumnTitle("custom2").Content(@<div>
                @WebUI.Control.Button().Text("btn").Type(ButtonTypeEnum.button).Render()
            </div>)

            @tb.Columns.AddLabel().ColumnTitle("Label").Value(x => "<span style='color:cornflowerblue;'>Label</span>")

            @tb.Columns.AddTextbox().ColumnTitle("Textbox").Value(x => "Textbox").Name(x => "tt")

            @tb.Columns.AddSelector().ColumnTitle("Selector").CurrentValue(x => "0").Name(x => "ss").FirstItem(new SelectorItem("select", "-1")).Options(new[] { new SelectorItem("s0", "0"), new SelectorItem("s1", "1"), })

            @tb.Columns.AddTextboxWithButton().ShowDataPicker((x, y) => y.SetUrl("/Home/DataPicker").OnSelectedCallback("OnSelectedCallback").OnShowCallback("OnShowCallback")).ColumnTitle("TextboxWithButton").TextboxReadOnly(true).Name(x => "tb").Value(x => "ddd").WithHiddenValue(x => ("101", "tbID")).ButtonColor(ColorPaletteEnum.success).ButtonText("select")
        }
    }

    @frm.AddTextBoxWithButton().SelectedOnClick().Label("textboxwithbutton").Value("sdfsdfsd").Name("dddd").Render()

    @frm.AddTextBoxWithButton().ShowDataPicker("/Home/DataPicker",new JObject()
                                                                  {
                                                                      {"#dss","ssss" }
                                                                  }).SelectedOnClick().Label("datapicker").Value("sdfsdfsd").Name("dddd").Render()


    @frm.AddRadioList().Label("radiolist").Options(new[]
    {
         new SelectorItem("sss", "sss1"),
         new SelectorItem("sss44", "sss"),
     }).Checked("sss1").Name("dddd").Render()

    @frm.AddFileUpload().UploadUrl("/Home/UploadFile").Label("fileupload").Src("").Name("dddd").Render()

    @frm.AddImageUpload().UploadUrl("/Home/UploadFile").Label("imageupload").Src("").Name("dddd").Render()

    @frm.AddCityPicker().Level(CityPickerLevelEnum.district).ValueByName("安徽省/阜阳市/临泉县").WithAddressBox("", "sdfsdfd").Label("citypicker").Name("dddd").Render()

    @frm.AddMultiFileUpload().UploadUrl("/Home/UploadFile").Label("multifileupload").Name("dddd").Render()

    @(frm.AddButtonList()
          .AddButton(btn=>btn.Text("goto").Href("InnerTest1", LinkTargetType.Blank))
          .AddButton(x => x.Text("ShowFileViewer").OnClick("WebUIJS.ShowFileViewer('/dummy.pdf')").Type(ButtonTypeEnum.button).Color(ColorPaletteEnum.warning))
          .Render())
}
